]> git.r.bdr.sh - rbdr/super-polarity/blame - Super Polarity/BasicGenerator.cs
Stuffffffff
[rbdr/super-polarity] / Super Polarity / BasicGenerator.cs
CommitLineData
097781e6
BB
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6
7namespace SuperPolarity
8{
9 class BasicGenerator
10 {
11 public enum Ships : byte { Ship, Scout, Battlecruiser };
12
13 protected Ships ShipType;
14 protected SuperPolarity Game;
15 protected int ScoreThreshold;
16 protected int Rate;
17 protected int CurrentTime;
18 protected Random Randomizer;
19 protected Vector2 Position;
20
21 public void Initialize(SuperPolarity game, Vector2 position, Ships shipType, int rate, int scoreThreshold)
22 {
23 Game = game;
24 ShipType = shipType;
25 ScoreThreshold = scoreThreshold;
26 Rate = rate;
27 Randomizer = new Random();
28 Position = position;
29 }
30
31 public void Update(GameTime gameTime)
32 {
33 if (Game.Player.Score > ScoreThreshold)
34 {
35 CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
36
37 if (CurrentTime >= Rate)
38 {
39 CurrentTime = 0;
40 Spawn();
41 }
42 }
43 }
44
45 protected void Spawn()
46 {
47 var polarity = Ship.Polarity.Positive;
48
49 if (Randomizer.Next(2) == 1)
50 {
51 polarity = Ship.Polarity.Negative;
52 }
53
54 if (ShipType == Ships.Ship)
55 {
56 ActorFactory.CreateShip(polarity, Position);
57 }
58
59 if (ShipType == Ships.Scout)
60 {
61 ActorFactory.CreateScout(polarity, Position);
62 }
63
64 if (ShipType == Ships.Battlecruiser)
65 {
66 ActorFactory.CreateCruiser(polarity, Position);
67 }
68
69 }
70 }
71}